<?php
require_once '../sub/init.php';
header("Cache-control: private");
require_once 'chkUadm.php';
if(!in_array('315',$QXARR))exit(noauth());
require_once ZEAI.'sub/zeai_up_func.php';
switch ($submitok) {
	case"alldel":
		$tmeplist = $list;
		if(empty($tmeplist))json_exit(array('flag'=>0,'msg'=>'请选择您要删除的信息'));
		if(!is_array($tmeplist))exit(JSON_ERROR);
		if(count($tmeplist)>=1){
			foreach($tmeplist as $value){$v=intval($value);
				$row2 = $db->ROW(__TBL_TEXT__,"uid,content","id=".$v,'num');$uid= $row2[0];$content= $row2[1];
				$row2 = $db->ROW(__TBL_USER__,"nickname","id=".$uid,'num');$nickname= $row2[0];
				AddLog('【注销管理】删除【'.$nickname.'（uid:'.$uid.'）】注销记录->ID:'.$v.'，注销原因：'.$content);
				$db->query("DELETE FROM ".__TBL_TEXT__." WHERE id=".$v);
			}
		}
		json_exit(array('flag'=>1,'msg'=>'删除成功'));
	break;
	case"ajax_flag":
		if ( !ifint($id))json_exit(array('flag'=>0,'msg'=>'ID跑路了'));
		$db->query("UPDATE ".__TBL_TEXT__." SET flag=1 WHERE flag=0 AND id=".$id);
		AddLog('【注销管理】处理注销信息ID:'.$id);
		json_exit(array('flag'=>1,'msg'=>'操作成功'));
	break;
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="<?php echo HOST;?>/res/www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="css/main.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css">
<style>.box{min-width:1000px}</style>
</head>
<body>
<div class="box">
	<div class="boxL">
        <a href="315.php">用户举报管理</a>
        <a href="udel.php" class="ed">用户注销管理</a>
	</div>
	<div class="boxR">
        <div class="topsearch">
        <form name="ZEAI_CN__form1" method="get" action="<?php echo SELF; ?>">
            <input name="Skeyword" type="text" id="Skeyword" maxlength="25" class="input size2 W200" placeholder="按注销人UID/用户名/昵称" value="<?php echo $Skeyword; ?>">
            <input type="hidden" name="p" value="<?php echo $p;?>" />
            <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
        </form>
        <form name="ZEAI_CN__form2" method="get" action="<?php echo SELF; ?>" style="margin-left:30px">
            <input name="Skeyword2" type="text" id="Skeyword2" maxlength="25" class="input size2 W150" placeholder="按注销内容" value="<?php echo $Skeyword2; ?>">
            <input type="hidden" name="p" value="<?php echo $p;?>" />
            <button type="submit" class="btn size2"><i class="ico">&#xe6c4;</i> 搜索</button>
        </form>  
        </div>
        <!---->
		<?php
        $SQL = "";
        $Skeyword = trimm($Skeyword);
        if (ifint($Skeyword)){
            $SQL = " AND (b.id=$Skeyword) ";
        }elseif(!empty($Skeyword)){
            $SQL = " AND ( ( b.uname LIKE '%".$Skeyword."%' ) OR ( b.nickname LIKE '%".$Skeyword."%' ) OR ( b.nickname LIKE '%".urlencode($Skeyword)."%' ) )";
        }
        if(!empty($Skeyword2)){
            $SQL = " AND ( a.content LIKE '%".$Skeyword2."%' )";
        }
        switch ($sort) {
            default:$SORT = " ORDER BY flag,id DESC ";break;
        }
        if ($f=='f0')$SQL .= " AND a.flag=0";
        $rt = $db->query("SELECT a.*,b.sex,b.grade,b.nickname,b.photo_s FROM ".__TBL_TEXT__." a,".__TBL_USER__." b WHERE a.uid=b.id ".$SQL.$SORT." LIMIT ".$_ADM['admLimit']);
        $total = $db->num_rows($rt);
        if ($total <= 0 ) {
            echo "<div class='nodataico'><i></i>暂无内容<br><a class='aQINGed' href='javascript:history.back(-1)'>返回</a></div>";
        } else {
            $page_skin=2;$pagemode=3;$pagesize=$_ADM['admPageSize'];require_once ZEAI.'sub/page.php';?>
            <form id="www_zeai_cn_FORM" method="get" action="<?php echo SELF; ?>">
            <table class="tablelist">
            <tr>
            <th width="20"><input type="checkbox" id="checkboxall1" class="checkskin checkboxall"><label for="checkboxall1" class="checkskin-label"><i class="i1"></i></label></th>
            <th width="50">ID</th>
            <th width="50">头像</th>
            <th width="170" align="left">提交注销用户UID/昵称</th>
            <th>注销原因</th>
            <th width="70" align="center">注销时间</th>
            <th width="80" align="center">状态/操作</th>
            <th width="20" align="center">&nbsp;</th>
            </tr>
            <?php
            for($i=1;$i<=$pagesize;$i++) {
                $rows = $db->fetch_array($rt,'name');
                if(!$rows) break;
                $id = $rows['id'];$uid = $rows['uid'];
                $uname = strip_tags($rows['uname']);
                $uname = str_replace($Skeyword,"<font color=red><b>".$Skeyword."</b></font>",$uname);
                $nickname = dataIO($rows['nickname'],'out');
                $nickname = str_replace($Skeyword,"<font color=red><b>".$Skeyword."</b></font>",$nickname);
                $sex       = $rows['sex'];
                $grade     = $rows['grade'];
                if(empty($rows['nickname'])){
                    $nickname = $uname;
                }
                $content = dataIO($rows['content'],'out');
                $content = str_replace($Skeyword2,"<font color=red><b>".$Skeyword2."</b></font>",$content);
        
                $addtime = YmdHis($rows['addtime']);
                $flag    = $rows['flag'];
				$photo_s = $rows['photo_s'];
				$photo_s_url = (!empty($photo_s))?UP.$photo_s:RES.'photo_s'.$sex.'.png';
				$title2 = (!empty($nickname))?urlencode(trimhtml($nickname)).'／'.$uid:$uid;
            ?>
            <tr id="tr<?php echo $id;?>">
                <td width="20" height="40"><input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $senduid; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
                </td>
              <td width="50" class="C999"><label for="id<?php echo $id; ?>"><?php echo $id;?></label></td>
              <td width="50" class="C999"><a href="javascript:;" photo_s_url="<?php echo $photo_s_url;?>" class="photo_s" uid="<?php echo $uid;?>" title2="<?php echo $title2;?>" title="浏览个人主页"><img src="<?php echo $photo_s_url;?>" class="photo_s40 yuan"></a></td>
                <td width="170" align="left">
    <a href="javascript:;" uid="<?php echo $uid;?>" title2="<?php echo $title2;?>" class="photo_s" photo_s_url="<?php echo $photo_s_url;?>">
    <?php echo uicon($sex.$grade) ?><?php echo '<font>'.$uid.'</font></br>';?></a>
    <font class="uleft">
    <?php
    if(!empty($rows['mob']))echo $mob."</br>";
    echo $nickname;
    ?>
    </font>
                </td>
              <td align="left" class="S14"><?php echo $content; ?>      </td>
              <td width="70" align="center" class="C999"><?php echo $addtime;?></td>
              <td width="80" align="center" class="lineH200">
                    <?php
                    if($flag==1){
                        echo'<font class="C090">已处理</font><br>';
                    }else{
                        echo'<font class="Cf00">未处理</font><br>';?>
                        <a href="javascript:;" class="btn size2 cl" value="<?php echo $id;?>">确定处理</a>
                    <?php }?>      
              </td>
              <td width="20" align="center" class="lineH200">&nbsp;</td>
              </tr>
            <?php } ?>
            </table>
            </form>
        <?php }?>
        <!---->
	</div>
    <div class="clear"></div>
</div>
<?php if ($total > 0 ) {?>
<div class="listbottombox">
	<input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
    <button type="button" id="btndellist" class="btn size2 HEI2 disabled action">批量删除</button>　
    <!--<button type="button" id="btnsend" value="" class="btn size2 disabled action" onClick="sendTipFn2(this);"><i class="ico">&#xe676;</i> 发送消息</button>-->
    <input type="hidden" name="submitok" id="submitok" value="" />
	<?php if ($total > $pagesize)echo '<div class="pagebox FR">'.$pagelist.'</div>'; ?>
</div>
<script>
var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';
o('btndellist').onclick = function() {
	allList({
		btnobj:this,
		url:'udel'+zeai.ajxext+'submitok=alldel',
		title:'批量删除',
		msg:'正在删除中...',
		ifjson:true,
		ifconfirm:true
	});	
}
zeai.listEach('.cl',function(obj){
	obj.onclick = function(){
		zeai.confirm('确定处理完成了么？',function(){
			var id = parseInt(obj.getAttribute("value"));
			zeai.ajax({url:'udel'+zeai.extname,data:{submitok:'ajax_flag',id:id}},function(e){var rs=zeai.jsoneval(e);
				zeai.msg(0);zeai.msg(rs.msg);
				if(rs.flag==1){setTimeout(function(){location.reload(true);},1000);}
			});
		});
	}
});
zeai.listEach('.photo_s',function(obj){
	obj.onclick = function(){
		var uid = parseInt(obj.getAttribute("uid"));
		var title2 = obj.getAttribute("title2");
		var photo_s_url = decodeURIComponent(obj.getAttribute("photo_s_url"));
		crm_homepage({uid:uid,title2:title2,photo_s_url:photo_s_url});
	}
});
</script>
<script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
<?php require_once 'bottomadm.php';?>